package com.dlwx.firefighting.utils.glide;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.dlwx.firefighting.R;
import com.dlwx.firefighting.bean.HomeBean;
import com.youth.banner.loader.ImageLoader;

/**
 * Created by Administrator on 2017/3/27.
 */

public class ImageLoaderComm extends ImageLoader {
    private Object object;
    public ImageLoaderComm(Object object) {
        this.object = object;
    }

    @Override
    public void displayImage(Context context, Object path, ImageView imageView) {
        //Glide 加载图片简单用法
//        imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        if(object instanceof HomeBean.ContentBean){
            diplayBanner( context,  path,  imageView);
        }else  if(object instanceof String){
            diplayString( context,  path,  imageView);
        }
    }

    private void diplayString(Context context, Object path, ImageView imageView) {
        Glide.with(context).load(path).error(R.mipmap.product).into(imageView);
    }

    private void diplayBanner(Context context, Object path, ImageView imageView) {
        Glide.with(context).load(((HomeBean.ContentBean)path).getImage_mobile()).error(R.mipmap.product).into(imageView);

    }

}
